<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="utf-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1">
  <title></title>
  <link rel="stylesheet" href="../style/css/bootstrap.min.css">
  <link rel="stylesheet" href="../style/css/common.css">
</head>

<body>
  <div class="container">
    <ul class="nav nav-tabs mb20">
      <li><a href="index.html">检测人脸</a></li>
      <li><a href="compareCode.html">相似度比较</a></li>
      <li><a href="centerFace.html">检测最中心人脸</a></li>
      <li class="active"><a href="addFeature.html">添加特征码</a></li>
      <li><a href="../jQuery/index.html" target="_blank">切换版本</a></li>
      <li><a href="../index.html">返回首页</a></li>
    </ul>
    <div class="div-upload">
      <div class="div-btn">
        <button type="button" class="btn btn-default btn-blue">点击上传</button>
        <button type="button" class="btn btn-default btn-blue submit">点击添加</button>
      </div>
      <div class="tips">
        <p>提取特征码调用的接口：detectAndGetCodeInfo</p>
        <p>参数解析：imgBlob: 照片的二进制流，0：faceNum的值</p>
        <p>举例：client.detectAndGetCodeInfo(imgBlob, 0, function (data) {})</p>
      </div>
      <div class="tips">
        <p>添加到内存条调用的接口：addFeatureToFse</p>
        <p>参数解析：featureId：特征码ID，可为null, feature：照片的特征码数组, imgMD5：特征所属图的MD5，可为null</p>
        <p>举例：clientSe.addFeatureToFse(null,codeArr[i].code,null,function (data) {})</p>
      </div>
      <input type="file" onchange="previewImage(this)" id="photoimg" class="btn-file" />
      <div class="preview prevPic" id="preview"><img src="" alt="" /></div>
      <div class="picStr" id="code1"></div>
    </div>
    <!-- 提示语 -->
    <div class="box">
      <div class="msg">提示成功</div>
    </div>
  </div>
  <script src="../style/js/jquery.min.js"></script>
  <script src="js/thrift.js"></script>
  <script src="js/FaceApi.js"></script>
  <script src="js/FaceApi_types.js"></script>
  <script src="js/FeatureSe.js"></script>
  <script src="js/FeatureSe_types.js"></script>
  <script src="js/common.js"></script>
  <script src="js/preview.js"></script>
  <script>
    // 获取特征码
    codeArr = [];
    function getCode(imgBlob, prevDiv) {
      client.detectAndGetCodeInfo(imgBlob, 0, function (data) {
        codeArr = data;
      }).fail(function (jqXHR, status, error) {
        $('.box').show().delay(3000).fadeOut();
        $('.box').find('.msg').text(status + ":" + error);
        prevDiv.innerHTML = '<img src="" alt="" />';
      })
    }


    // 点击获取
    var clientSe = new FeatureSeClient(protocol);
    $('.submit').click(function() {
      for(var i =0; i< codeArr.length; i++){
        clientSe.addFeatureToFse(null,codeArr[i].code,null,function (data) {
          $('.box').show().delay(3000).fadeOut();
          $('.box').find('.msg').text('添加成功');
        })
      }
    })
  </script>
</body>